package edu.uow.scsse.main.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * Graph of trigging event domain
 * @author Tiancheng Zhang
 */
public class Graph {
	/**node with edges list*/
	List<Node> nodes;


	/**
	 * Constructor for Graph
	 */
	public Graph() {
		nodes = new ArrayList<Node>();
	}

	
	/**
	 * Constructor for Graph
	 * @param nodes
	 */
	public Graph(List<Node> nodes) {
		this.nodes = nodes;
	}

	/**
	 * @return the nodes
	 */
	public List<Node> getNodes() {
		return nodes;
	}

	/**
	 * @param nodes the nodes to set
	 */
	public void setNodes(List<Node> nodes) {
		this.nodes = nodes;
	}
	
	/**
	 * Find a node in graph
	 * @param toFind
	 * @return the node
	 */
	public Node findNode(Node toFind)
	{
		return nodes.get(nodes.indexOf(toFind));
	}
	
	/**
	 * Find node in graph accoring to node name and type
	 * @param name
	 * @param type
	 * @return
	 */
	public Node findNodeById(int id)
	{
//		Node toFind = new Node(id, null, null, null , null, null);
		for(int i = 0; i < nodes.size(); i++)
		{
			if(nodes.get(i).getId() == id)
				return nodes.get(i);
		}
		return null;
	}
	
}
